package com.lance.springbootes.controller;

import com.lance.springbootes.model.Goods;
import com.lance.springbootes.repository.GoodsRepository;
import com.lance.springbootes.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Classname GoodsController
 * @Description
 * @Date 2022/2/21 13:31
 * @Author lance
 */
@RestController
@RequestMapping("goods")
public class GoodsController {

    @Autowired
    GoodService goodService;

    @RequestMapping("addToEs")
    public List<Goods> addToEs(String keyword){
        return goodService.addToEs(keyword);
    }

    @GetMapping("getData/{keyword}/{current}/{size}")
    public Map<String,Object> getData(
            @PathVariable("keyword") String keyword,
            @PathVariable("current") int current,
            @PathVariable("size") int size
                               ){
        return goodService.getData(keyword,current,size);
    }

    @GetMapping("getHighLightData/{keyword}/{current}/{size}")
    public Map<String,Object> getHighLightData(
            @PathVariable("keyword") String keyword,
            @PathVariable("current") int current,
            @PathVariable("size") int size
    ){
        return goodService.getHighLightData(keyword,current,size);
    }
}
